@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

set allparam=

:param
set str=%1
if "%str%"=="" (
    goto end
)
set allparam=%allparam% %str%
shift /0
goto param

:end
if "%allparam%"=="" (
    goto eof
)

rem remove left right blank
:intercept_left
if "%allparam:~0,1%"==" " set "allparam=%allparam:~1%"&goto intercept_left

:intercept_right
if "%allparam:~-1%"==" " set "allparam=%allparam:~0,-1%"&goto intercept_right

:eof

for %%f in (%allparam%)  do  (
  rem echo %%f
  set ftime=%time:~0,2%%time:~3,2%%time:~6,2%
  rem echo !ftime!
  set fullfilename="%%f"
  rem echo !fullfilename!
  set filename=%%~nf
  rem echo !filename!
  set ext=%~x0
  rem echo !ext!

  rem ffmpeg -i "%filename%%ext%" -c:v h264_qsv -preset 4 -y "%filename%_%ftime%.mp4"
  rem ffmpeg -i "%filename%%ext%" -c:v h264_qsv  -crf 20 -map_metadata 0  "%filename%_%ftime%.mp4" -y
  echo ffmpeg -i !fullfilename! -c:v h264_qsv  -preset 4 -map_metadata 0  "d:\out\!filename!.mp4" -y
  ffmpeg -i !fullfilename! -c:v h264_qsv  -global_quality 22 -map_metadata 0  "d:\out\!filename!.mp4" -y
)

pause
